<?php if (!defined('FIT_PATH')) exit('No direct script access allowed');
/**
 * @copyright 2009 - 2011 Bincent.com. All Rights Reserved.
 * @license http://www.apache.org/licenses/LICENSE-2.0
 * @package FitPHP
 * @subpackage core
 * 
 * @author Hongbin Hsu <hongbin.hsu@gmail.com> Initial.
 * @version $Id: core/controller.php 1.1 2010-09-18 16:52 hongbin.hsu $
 */
 
// ------------------------------------------------------------------------

abstract class Controller extends Base
{
	protected $loader;
	
	//----------------------------------------------------------
	/**
	 * 构造控制器
	 *
	 * @return void
	 */
	public function __construct()
	{
		parent::__construct();
		$this->initialize();
	}
	
	//----------------------------------------------------------
	/**
	 * 初始化控制器
	 *
	 * @return void
	 */
	public function initialize()
	{
		$this->loader = new Loader();
	}
	
	//----------------------------------------------------------
	/**
	 * 获取Loader对象私有属性
	 *
	 * @param string $name
	 * @return object
	 */
	public function __get($name)
	{
		return (isset($this->$name)) ? $this->$name : $this->loader->$name;
	}
	
	//----------------------------------------------------------
	/**
	 * 当没有方法时使用，默认方法并把后面的做为参数传递
	 *
	 * @param string $method
	 * @param array $arguments
	 */
	public function __call($method, $arguments)
    {
        call_user_func_array(array(self, Application::$default_method), array_slice(array_merge(array($method), $arguments), 0));
    }
}